package cn.sptpc.Controller;

import cn.sptpc.service.GroupService;
import cn.sptpc.service.impl.GroupServiceI;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/group.do")
public class GroupServlet extends HttpServlet {
    private GroupService service = new GroupServiceI();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/json;charset=gbk");
        String tran = request.getParameter("tran");
        if ("select".equals(tran)){
            String type = request.getParameter("type");
            if("all".equals(type)){

            }else if ("id".equals(type)){
                int departmentId =Integer.parseInt(request.getParameter("departmentId")) ;
                String allGroupByDeparment = service.getAllGroupByDeparment(departmentId);
                response.getWriter().write(allGroupByDeparment);
            }
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
